package com.dongdong.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdong.data.Result;
import com.dongdong.em.ResultEmnu;
import com.dongdong.pojo.TbContent;
import com.dongdong.service.ContentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("content")
public class ContentController {
    @Reference(timeout = 5000)
    private ContentService contentService;
    @RequestMapping("contentList")
    @ResponseBody
    public Result contentList(){
        try {
            List<TbContent> contentList = contentService.selectByCategoryId();
            return Result.respone(ResultEmnu.SUCCESS).setData(contentList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.respone(ResultEmnu.ERROR);
        }
    }
    @RequestMapping("recommed")
    @ResponseBody
    public Result recommed(){
        try {
            List<TbContent> contentList = contentService.selectRecommed();
            return Result.respone(ResultEmnu.SUCCESS).setData(contentList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.respone(ResultEmnu.ERROR);
        }
    }
    @RequestMapping("yourLike")
    @ResponseBody
    public Result yourLike (){
        try {
            List<TbContent> contentList = contentService.selectyourLike();
            return Result.respone(ResultEmnu.SUCCESS).setData(contentList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.respone(ResultEmnu.ERROR);
        }
    }

}
